home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / RKPLUS20.ARJ / RKPLUS.DOC < prev    next >
Text File  |  1991-02-08  |  37KB  |  1,048 lines

  1.  
  2.  
  3.                     RkPlus 2.0 (c) 1991 Serious Cybernetics
  4.                      Turbo Pascal(tm) Registration Key Unit
  5.                                by C. Scott Davis
  6.  
  7.  
  8. -------------------------------------------------------------------------------
  9.  
  10.  
  11. RkPlus is an enhanced version of the rKey Registration Key Unit.  It is a Turbo
  12. Pascal (tm) Unit designed to allow programmers to easily handle registration
  13. keys in their software.  All of the key encryption, checking and key file
  14. routines are handled in RkPlus, requiring little effort on the part of the
  15. programmer.  It can allow anything from simple registration messages to
  16. multiple registration levels and limited use demo keys.
  17.  
  18.  
  19. There are two versions of RkPlus included here.  RKPLUS.TPU runs under Turbo
  20. Pascal (tm) 5.5 and RK6PLUS.TPU runs under Turbo Pascal (tm) 6.0.  If you don't
  21. feel that you need all of the enhanced features of RkPlus, you should obtain a
  22. copy of rKey. The latest version of rKey and RkPlus (as well as other Serious
  23. Cybernetics software) are always available for download and Fido file request
  24. from Phoenix StarFighter BBS (see phone number and Fido address below).
  25.  
  26.  
  27. All of the sample programs use RKPLUS.TPU.  If you are using Turbo Pascal (tm)
  28. 6.0 and need the sample programs to use RK6PLUS.TPU, simply change :
  29.  
  30.   Uses
  31.     RkPlus;
  32.  
  33. to
  34.  
  35.   Uses
  36.     Rk6Plus;
  37.  
  38.  
  39. The various sample programs demonstrate 2 methods of handling keys :
  40.  
  41.   Method 1 : Distribute your program (for example, RKPDEMO.EXE) and use
  42.              a key file generation program (like RKPGFILE.EXE), which you
  43.              do NOT distribute, to create a key file for each user who
  44.              registers.  You then send the user the key file.
  45.  
  46.   Method 2 : Distribute your program (for example, RKPDEMO.EXE) and a
  47.              branding program (like RKPBRAND.EXE).  You then use a key
  48.              generation program (like RKPGKEY.EXE), which you do NOT
  49.              distribute, to create a a key number for each user who
  50.              registers.  You then send the user the key number, which
  51.              he/she enters into the brand program to create a key file.
  52.  
  53.  
  54. -------------------------------------------------------------------------------
  55.  
  56.  
  57. The following Types are defined in RkPlus :
  58.  
  59. Type
  60.   RegStatType = (
  61.                   NotRegistered,
  62.                   Registered,
  63.                   ExpiredKey,
  64.                   InvalidKey,
  65.                   FileError,
  66.                   NullOwnerCode,
  67.                   NullProgramCode,
  68.                   InvalidFile
  69.                 );
  70.   RegRec      = Record
  71.                   Status   : RegStatType;
  72.                   KeyPath  : String[79];
  73.                   ID       : String[36];
  74.                   Name1    : String[36];
  75.                   Name2    : String[36];
  76.                   Name3    : String[36];
  77.                   Message  : String[36];
  78.                   Level    : Byte;
  79.                   ExpYear  : Word;
  80.                   ExpMonth : Word;
  81.                   Key      : String[12];
  82.                 End;
  83.  
  84.  
  85. The following Constants are defined in RkPlus :
  86.  
  87.   RkPlusVer = '2.0';         { contains the current version of RkPlus }
  88.  
  89.  
  90. The following Variables are defined in RkPlus :
  91.  
  92.   OwnerCode     : String[20];
  93.   ProgramCode   : String[16];
  94.   KeyFile       : String[8];
  95.   BadSystemDate : Boolean;
  96.   Reg           : RegRec;
  97.  
  98.  
  99. The following Procedures and Functions are defined in RkPlus :
  100.  
  101. Function MakeKey(s1,s2,s3 : String;l : Byte;ey,em : Word) : String;
  102. Function ValidKey(s1,s2,s3 : String;l : Byte;k : String) : Boolean;
  103. Procedure SetRegInfo(t,s1,s2,s3,m : String;l : Byte;ey,em : Word;k : String);
  104. Procedure CreateKey;
  105. Procedure VerifyKey;
  106. Procedure GetRegInfo;
  107. Procedure SaveRegInfo;
  108.  
  109.  
  110. -------------------------------------------------------------------------------
  111.  
  112.  
  113. OwnerCode : String[20];
  114.  
  115. This variable is initialized by RkPlus to '' and must be assigned a value
  116. before calling any of the RkPlus procedures or functions.  It is used (along
  117. with ProgramCode) to generate the registration keys.  This variable should
  118. probably be the same for all software written by a single person/company.
  119. Since is it used to cause your keys to be different from those of other
  120. programmers who are also using RkPlus, the more cryptic this variable is,
  121. the more secure your keys will be.
  122.  
  123.  
  124. Examples :
  125.  
  126.   OwnerCode := 'TrendSoft, Inc.';
  127.  
  128. {
  129.  If the name of your company is 'TrendSoft, Inc.', this is probably NOT a good
  130.  OwnerCode.  It would be easy for someone who knows the name of the company
  131.  to use the RkPlus unit to write a program that will generate keys for your
  132.  software.
  133. }
  134.  
  135.   OwnerCode := 'Trend&&Soft/Inc@';
  136.  
  137. {
  138.  This is better.  It still uses the name of the company, but it is somewhat
  139.  masked by the insertion of other characters and would be harder for another
  140.  programmer to guess.
  141. }
  142.  
  143.   OwnerCode := 'Read$Make@Into';
  144.  
  145. {
  146.  This is MUCH better.  It uses totally unrelated words that would be extremely
  147.  unlikely to be used by another programmer/company.
  148. }
  149.  
  150.   OwnerCode := 'EkQW3#m,-%\uSaXo^Ej7';
  151.  
  152. {
  153.  This is most likely the best, since it uses totally random symbols.
  154. }
  155.  
  156. IMPORTANT : You should NOT use any of the actual examples used here or in
  157.             the sample programs included with RkPlus.  If you do, anyone else
  158.             who uses the same example will have IDENTICAL keys!
  159.  
  160.  
  161. -------------------------------------------------------------------------------
  162.  
  163.  
  164. ProgramCode : String[16];
  165.  
  166. This variable is initialized by RkPlus to '' and must be assigned a value
  167. before calling any of the RkPlus procedures or functions.  It is used (along
  168. with OwnerCode) to generate the registration keys.  Unlike OwnerCode, it
  169. doesn't neep to be particularly cryptic.  There are several approaches to the
  170. use of ProgramCode :
  171.  
  172.   (1) If ProgramCode is set to the same value for several programs
  173.       written by a person/company, keys for one piece of software will
  174.       work on another piece of software.  Using this approach, you
  175.       could have a single key for several programs.
  176.  
  177.   (2) If each program has a different ProgramCode and the ProgramCode is
  178.       not changed when the program changes, keys for one version of the
  179.       program will work for all versions of the same program.
  180.  
  181.   (3) If each program has a differenct ProgramCode and the ProgramCode is
  182.       changed when the program is changed, a different key will be
  183.       required for each version of the program.
  184.  
  185.  
  186. Examples :
  187.  
  188.   ProgramCode := 'RkStuff';
  189.  
  190. {
  191.  If you wrote a program called RkSample and a program called RkUtils and
  192.  you defined the ProgramCode as 'RkStuff' in both programs, a key for one
  193.  program would work for the other.
  194. }
  195.  
  196.   ProgramCode := 'RkSample';
  197.  
  198. {
  199.  If you wrote a program called RkSample and a program called RkUtils and
  200.  you defined the ProgramCode as 'RkSample' in RkSample and used a different
  201.  ProgramCode in RkUtils, a key for one would NOT work for the other.
  202. }
  203.  
  204.   ProgramCode := 'RkSample One';
  205.  
  206. {
  207.  If you wrote a program called RkSample and you defined the ProgramCode as
  208.  'RkSample One' in versions 1.1, 1.2 and 1.3 and then changed the
  209.  ProgramCode to 'RkSample Two' for version 2.0, the same key would work for
  210.  versions 1.1, 1.2 and 1.3 but would NOT work for version 2.0.
  211. }
  212.  
  213.  
  214. -------------------------------------------------------------------------------
  215.  
  216.  
  217. KeyFile : String[8];
  218.  
  219. This variable is initialized by RkPlus to the name of the program (without path
  220. or extension).  If the name of the key file is to be different than the name of
  221. the program, this variable should be assigned a value before calling any of the
  222. RkPlus procedures or functions. It is the name of the keyfile that is read by
  223. GetRegInfo and written to by SaveRegInfo.  The extension will be '.REG'.
  224.  
  225.  
  226. Examples :
  227.  
  228.   KeyFile := 'RKSAMPLE';
  229.  
  230. {
  231.  The key file will be 'RKSAMPLE.REG'.  Key files are always created and read
  232.  from the same directory that the program is in.  This is true even if the
  233.  program is not in the current directory.
  234. }
  235.  
  236.  
  237. -------------------------------------------------------------------------------
  238.  
  239.  
  240. BadSystemDate : Boolean;
  241.  
  242. This variable is initialized by RkPlus to TRUE, if the current system date
  243. is 1-Jan-1980 (which usually indicates that the date was not set) or FALSE,
  244. if the current system date is anything other than 1-Jan-1980.
  245.  
  246. The main purpose for this variable is for use with limited keys (with embedded
  247. expiration dates).  By testing BadSystemDate, your program can handle
  248. situations where the system date was not set (therefore, causing expiration
  249. dates to be meaningless).
  250.  
  251.  
  252. Example :
  253.  
  254.   If BadSystemDate then Begin
  255.     WriteLn('The system date must be set!');
  256.     Halt(1);
  257.   End;
  258.  
  259. {
  260.   If the system date was not set (BadSystemDate = True) then display a message
  261.   and exit with an ErrorLevel of 1.
  262. }
  263.  
  264.  
  265. -------------------------------------------------------------------------------
  266.  
  267.  
  268. Reg.Status : RegStatType;
  269.  
  270. This field of the Reg record is initialized by RkPlus to NotRegistered.  It is
  271. set by CreateKey, VerifyKey, GetRegInfo and SaveRegInfo to the procedure
  272. result.
  273.  
  274. The following are possible values for Reg.Status :
  275.  
  276.   NotRegistered        Program is not registered
  277.   Registered           Program is registered
  278.   ExpiredKey           Key has expired
  279.   InvalidKey           Key is invalid
  280.   FileError            .REG file is corrupt
  281.   NullOwnerCode        OwnerCode has not been assigned a value
  282.   NullProgramCode      ProgramCode has not been assigned a value
  283.   InvalidFile          .REG file format error
  284.  
  285.  
  286. Examples :
  287.  
  288.   KeyFile := 'RKDEMO';
  289.   GetRegInfo;
  290.   If (Reg.Status = InvalidKey) then
  291.     WriteLn('The key file has been altered!')
  292.   Else If (Reg.Status = FileError) or (Reg.Status = InvalidFile) then
  293.     WriteLn('The key file is corrupt!');
  294.  
  295.  
  296. {
  297.  This will call GetRegInfo.  If the key contained in 'RKDEMO.REG' is invalid,
  298.  the message 'The key file has been altered!' will be displayed.  Otherwise,
  299.  if the file is corrupt or has a format error, the message 'The key file is
  300.  corrupt!' will be displayed.
  301. }
  302.  
  303.   KeyFile := 'RKDEMO';
  304.   GetRegInfo;
  305.   Write('RkDemo 1.5');
  306.   If (Reg.Status = NotRegistered) then
  307.     WriteLn('[unregistered]')
  308.   Else If (Reg.Status = Registered) then
  309.     WriteLn('[registered]')
  310.   Else If (Reg.Status = ExpiredKey) then
  311.     WriteLn('[expired key]')
  312.   Else
  313.     WriteLn('[invalid key]');
  314.  
  315. {
  316.  This will call GetRegInfo.  If the program is not registered, the message
  317.  'RkDemo 1.5 [unregistered]' will be displayed.  If the program is registered,
  318.  the message 'RkDemo 1.5 [registered]' will be displayed. If the key has
  319.  expired, the message 'RkDemo 1.5 [expired key]' will be displayed. Otherwise,
  320.  the message 'RkDemo 1.5 [invalid key]' will be displayed.
  321. }
  322.  
  323.  
  324. -------------------------------------------------------------------------------
  325.  
  326.  
  327. Reg.KeyPath : String[79];
  328.  
  329. This variable is initialized by RkPlus to ''.  GetRegInfo and Register will set
  330. Reg.KeyPath to the full directory, filename and extension of the key file.  If
  331. no key file was found, Reg.KeyPath will be set to ''.
  332.  
  333.  
  334. Examples :
  335.  
  336.   KeyFile := 'RKSAMPLE';
  337.   GetRegInfo;
  338.   If Reg.KeyPath <> '' then
  339.     WriteLn('Key file is ' + Reg.KeyPath);
  340.  
  341. {
  342.  The key file will be 'RKSAMPLE.REG'.  After GetRegInfo is called, Reg.KeyPath
  343.  will contain the full pathname of the the key file, which is displayed (if it
  344.  is not '').
  345. }
  346.  
  347.  
  348. -------------------------------------------------------------------------------
  349.  
  350.  
  351. Reg.ID : String[36];
  352.  
  353. This variable is initialized by RkPlus to ''.  Reg.ID is not used by RkPlus,
  354. and has no effect on key encryption.  However, it is read from the .REG file by
  355. GetRegInfo and written to the .REG file by SaveRegInfo.  This will allow you to
  356. ID your key files, so that your program can distinguish its own key files from
  357. those of other programs.
  358.  
  359.  
  360. Examples :
  361.  
  362.   KeyFile := 'RKDEMO';
  363.   GetRegInfo;
  364.   Write('RkInfo v6.1');
  365.   If (Reg.ID <> 'RkInfo') then
  366.     WriteLn('Error!  This is NOT an RkInfo key file!');
  367.  
  368. {
  369.  This will call GetRegInfo.  If Reg.ID doesn't equal 'RkInfo', then the
  370.  message 'Error!  This is NOT an RkInfo key file!' will be displayed.
  371. }
  372.  
  373.  
  374. -------------------------------------------------------------------------------
  375.  
  376.  
  377. Reg.Name1 : String;
  378.  
  379. This variable is initialized by RkPlus to ''.  It is used (along with Reg.Name2
  380. and Reg.Name3) in the encryption of the registration key, by CreateKey,
  381. VerifyKey and SaveRegInfo (which also writes it to the .REG file).  It is read
  382. from the .REG file, by GetRegInfo.  This will normally contain the name of the
  383. person that the software is registered to.
  384.  
  385.  
  386. Examples :
  387.  
  388.   KeyFile := 'RKDEMO';
  389.   GetRegInfo;
  390.   Write('RkDemo 1.5');
  391.   If (Reg.Status = NotRegistered) then
  392.     WriteLn('[unregistered]');
  393.   Else If (Reg.Status = Registered) then
  394.     WriteLn('[registered to ' + Reg.Name1 + ']')
  395.   Else
  396.     WriteLn('[invalid key]')
  397.  
  398. {
  399.  This will call GetRegInfo.  If the program is not registered, the message
  400.  'RkDemo 1.5 [unregistered]' will be displayed.  If the program is registered,
  401.  the message 'RkDemo 1.5 [registered to NAME]' will be displayed (with 'NAME'
  402.  replaced by the name of the person that the software is registered to).
  403.  Otherwise, the message 'RkDemo 1.5 [invalid key]' will be displayed. }
  404.  
  405.  
  406. -------------------------------------------------------------------------------
  407.  
  408.  
  409. Reg.Name2 : String;
  410.  
  411. This variable is initialized by RkPlus to ''.  It is used (along with Reg.Name1
  412. and Reg.Name3) in the encryption of the registration key, by CreateKey,
  413. VerifyKey and SaveRegInfo (which also writes it to the .REG file).  It is read
  414. from the .REG file, by GetRegInfo.  This may contain a company name, a BBS
  415. name, or any additional information that you want to use in key encryption.
  416.  
  417.  
  418. Examples :
  419.  
  420.   KeyFile := 'RKDEMO';
  421.   GetRegInfo;
  422.   WriteLn('RkDemo 1.5');
  423.   WriteLn;
  424.   If (Reg.Status = NotRegistered) then
  425.     WriteLn('Remember to Register!');
  426.   Else If (Reg.Status = Registered) then Begin
  427.     WriteLn('Registered to ' + Reg.Name1 + '.');
  428.     WriteLn('For use at ' + Reg.Name2 + '.');
  429.   End Else
  430.     WriteLn('Invalid key!')
  431.  
  432. {
  433.  This will call GetRegInfo.  If the program is not registered, the message
  434.  'Remember to Register!' will be displayed.  If the program is registered, the
  435.  messages 'Registered to NAME' will be displayed (with 'NAME' replaced by the
  436.  name of the person that the software is registered to) and 'For use at
  437.  LOCATION' will be displayed (with 'LOCATION' replaced by the the value of
  438.  Reg.Name2).  Other person that the software is registered to) and.  Otherwise,
  439.  the message 'Invalid key!' will be displayed.
  440.  }
  441.  
  442.  
  443. -------------------------------------------------------------------------------
  444.  
  445.  
  446. Reg.Name3 : String;
  447.  
  448. This variable is initialized by RkPlus to ''.  It is used (along with Reg.Name1
  449. and Reg.Name2) in the encryption of the registration key, by CreateKey,
  450. VerifyKey and SaveRegInfo (which also writes it to the .REG file).  It is read
  451. from the .REG file, by GetRegInfo.  This may contain a customer number,
  452. address, or any additional information that you want to use in key encryption.
  453.  
  454.  
  455. Examples :
  456.  
  457.   KeyFile := 'RKDEMO';
  458.   GetRegInfo;
  459.   WriteLn('RkDemo 1.5');
  460.   WriteLn;
  461.   If (Reg.Status = NotRegistered) then
  462.     WriteLn('Remember to Register!');
  463.   Else If (Reg.Status = Registered) then Begin
  464.     WriteLn('Registered to ' + Reg.Name1 + '.');
  465.     WriteLn('              ' + Reg.Name2 + '.');
  466.     WriteLn('              ' + Reg.Name3 + '.');
  467.   End Else
  468.     WriteLn('Invalid key!')
  469.  
  470. {
  471.  This will call GetRegInfo.  If the program is not registered, the message
  472.  'Remember to Register!' will be displayed.  If the program is registered, the
  473.  message 'Registered to NAME' will be displayed (with 'NAME' replaced by the
  474.  name of the person that the software is registered to), followed by a 2 line
  475.  address (from Reg.Name2 and Reg.Name3).  Otherwise, the message 'Invalid key!'
  476.  will be displayed.
  477.  }
  478.  
  479.  
  480. -------------------------------------------------------------------------------
  481.  
  482.  
  483. Reg.Message : String[36];
  484.  
  485. This variable is initialized by RkPlus to ''.  Reg.Message is not used by
  486. RkPlus, and has no effect on key encryption.  However, it is read from the .REG
  487. file by GetRegInfo and written to the .REG file by SaveRegInfo.  This will
  488. allow you to ID your key files, so that your program can distinguish your key
  489. files from those of other programers/companies.
  490.  
  491.  
  492. Examples :
  493.  
  494.   KeyFile := 'RKDEMO';
  495.   GetRegInfo;
  496.   Write('RkInfo v6.1');
  497.   If (Reg.ID <> 'TrendSoft, Inc.') then
  498.     WriteLn('Error!  This is NOT a TrendSoft key file!');
  499.  
  500. {
  501.  This will call GetRegInfo.  If Reg.Message doesn't equal 'RkInfo', then the
  502.  message 'Error!  This is NOT a TrendSoft key file!' will be displayed.
  503. }
  504.  
  505. Note : You should NEVER set Reg.Message equal to OwnerCode!  This would cause
  506.        the value of OwnerCode to be written to your .REG files, and would
  507.        threaten the security of your registration keys.
  508.  
  509.  
  510. -------------------------------------------------------------------------------
  511.  
  512.  
  513. Reg.Level : BYTE;
  514.  
  515. This variable is initialized by RkPlus to 0.  It is used in the encryption of
  516. the registration key, by CreateKey, VerifyKey and SaveRegInfo (which also
  517. writes it to the .REG file).  It is read from the .REG file, by GetRegInfo.
  518. If you don't wish to use registration levels, Reg.Level should always be 0.
  519.  
  520.  
  521. Examples :
  522.  
  523.   KeyFile := 'RKMISC';
  524.   GetRegInfo;
  525.   WriteLn('RkMisc 2.1 Menu');
  526.   WriteLn;
  527.   WriteLn('[D]isplay demos');
  528.   If (Reg.Status = Registered) then Begin
  529.     WriteLn('[E]nter data');
  530.     WriteLn('[P]rint reports');
  531.     If Reg.Level > 0 then
  532.       WriteLn('[G]raphs');
  533.     If Reg.Level > 1 then
  534.       WriteLn('[O]ther functions');
  535.   End;
  536.  
  537. {
  538.  This will call GetRegInfo. If the software is unregistered, registered with
  539.  and expired key, or registered with an invalid key, the following menu will be
  540.  displayed :
  541.  
  542.    RkMisc 2.1 Menu
  543.  
  544.    [D]isplay demos
  545.  
  546.  If the software is registered at level zero (say for a $5 registration), the
  547.  following menu items would be available :
  548.  
  549.    RkMisc 2.1 Menu
  550.  
  551.    [D]isplay demos
  552.    [E]nter data
  553.    [P]rint reports
  554.  
  555.  If the software is registered at level one (say for a $10 registration), the
  556.  following menu items would be available :
  557.  
  558.    RkMisc 2.1 Menu
  559.  
  560.    [D]isplay demos
  561.    [E]nter data
  562.    [P]rint reports
  563.    [G]raphs
  564.  
  565.  If the software is registered at level two or higher (say for a $20 or more
  566.  registration), the following menu items would be available :
  567.  
  568.    RkMisc 2.1 Menu
  569.  
  570.    [D]isplay demos
  571.    [E]nter data
  572.    [P]rint reports
  573.    [G]raphs
  574.    [O]ther functions
  575.  
  576.  In this way you can allow different levels of registration to allow the
  577.  program to provide different functions, WITHOUT having distribute different
  578.  programs for each registration level.
  579. }
  580.  
  581. Note : Unlike the expiration date, which is binary encoded into the key
  582.        (and therefore can be extracted from any given key number), the
  583.        registration level is only used for the encryption of the key
  584.        and is stored in the key file (but can not be extracted from a
  585.        key number itself).  Therefore, if you use registration levels,
  586.        you will need to make sure that the brand program or key file
  587.        creation program knows the registration level, because it can
  588.        NOT be determined from the key number alone (see RkpBrand for
  589.        more examples).
  590.  
  591.  
  592. -------------------------------------------------------------------------------
  593.  
  594.  
  595. Reg.ExpYear  : Word;
  596. Reg.ExpMonth : Word;
  597.  
  598. These variables are initialized by RkPlus to 0.  They are binary-encoded into
  599. the registration key, by CreateKey and SaveRegInfo.  They are decoded from the
  600. registration key by VerifyKey and GetRegInfo. writes it to the .REG file).
  601. Valid values for Reg.ExpYear are 0 (No expiration) or 1991 to 2330.  Valid
  602. values for Reg.ExpMonth are 0 (No expiration) or 1 to 12. If you don't wish to
  603. use expiration dates, Reg.ExpYear and Reg.ExpMonth should always be 0.
  604.  
  605.  
  606. Examples :
  607.  
  608.   Const
  609.     Months : Array[1..12] of String[3] =
  610.     ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  611.  
  612.   KeyFile := 'RKPROG';
  613.   GetRegInfo;
  614.   If (Reg.Status = ExpiredKey) then
  615.     WriteLn('Your key expired 1-',Months(Reg.ExpMonth),'-',Reg.ExpYear)
  616.   Else If (Reg.Status = Registered) then
  617.     WriteLn('Your key will expire 1-',Months(Reg.ExpMonth),'-',Reg.ExpYear);
  618.  
  619. {
  620.  This will call GetRegInfo.  If the key has expired, the message 'Your key
  621.  expired 1-MONTH-YEAR' will be displayed (with 'MONTH' replaced by Reg.ExpMonth
  622.  and 'YEAR' replaced by Reg.ExpYear).  If the software is registered, the
  623.  message 'Your key will expire 1-MONTH-YEAR' will be displayed (with 'MONTH'
  624.  replaced by Reg.ExpMonth and 'YEAR' replaced by Reg.ExpYear).
  625. }
  626.  
  627.  
  628. -------------------------------------------------------------------------------
  629.  
  630.  
  631. Reg.Key : String[12];
  632.  
  633. This variable is initialized by RkPlus to '000000000000'.  It is set by
  634. CreateKey and GetRegInfo.  It is used by VerifyKey and SaveRegInfo. This
  635. contains the 12 digit alphanumeric registration key as a string.
  636.  
  637.  
  638. Examples :
  639.  
  640.   KeyFile := 'RKMORE';
  641.   GetRegInfo;
  642.   If (Reg.Status <> Registered) then Begin
  643.     WriteLn('This version of RkMore is not registered.');
  644.     WriteLn('Please read the READ.ME file for more info.');
  645.   End Else
  646.     WriteLn('This version of RkMore is registered to ' + Reg.Name1 + '.');
  647.     WriteLn('Registration key is ' + Reg.Key + '.');
  648.   End;
  649.  
  650. {
  651.  This will call GetRegInfo.  If the key contained in 'RKMORE.REG' is invalid
  652.  or the program is not registered, a message will be displayed telling the
  653.  user how to register the program.  Otherwise, the name of the person that
  654.  that the program is registered to and the registration key will be
  655.  displayed.
  656. }
  657.  
  658.  
  659. -------------------------------------------------------------------------------
  660.  
  661.  
  662. Function MakeKey(Name1,Name2,Name3 : String;
  663.                  Level : Byte;
  664.                  ExpYear,ExpMonth : Word) : String;
  665.  
  666. The function MakeKey will return a string containing the 12 digit registration
  667. registration key for Names and Level (using the pre-defined values of OwnerCode
  668. and ProgramCode) specified, with an encoded expiration date of ExpYear and
  669. ExpMonth.  If you do not wish to use registration levels, simply pass a 0 as
  670. the Level parameter.  If you do not wish to use expiration dates, simply pass 0
  671. as the ExpYear and ExpMonth parameters.  Unlike the higher-level CreateKey
  672. procedure, this function does NOT use or change the values of the Reg record.
  673.  
  674.  
  675. Examples :
  676.  
  677.   OwnerCode := 'AZ771N91P03DJSS447';
  678.   ProgramCode := 'RkProg';
  679.   WriteLn('Registration Key Maker for RkProg');
  680.   WriteLn;
  681.   WriteLn('FOR INTERNAL USE ONLY!');
  682.   WriteLn;
  683.   Write('Enter name : ');
  684.   ReadLn(n);
  685.   Write('Enter company : ');
  686.   ReadLn(c);
  687.   Write('Enter phone number (XXX) XXX-XXXX : ');
  688.   ReadLn(p);
  689.   k := MakeKey(n,c,p,0,0,0);    { registration levels and expiration dates
  690.                                   are not being used }
  691.   WriteLn;
  692.   WriteLn('Registration key is '+k);
  693.  
  694. {
  695.  This will display a warning message and then prompt for a name, company name
  696.  and phone number.  MakeKey is then passed the name, company name and phone
  697.  number, a 0 for the registration level and 0 for expiration year and month.
  698.  It will return the key in the variable k, which is then displayed.
  699.  
  700.  It is usually preferable to use the higher-level CreateKey procedure,
  701.  instead of MakeKey.  MakeKey is included to allow for situations where
  702.  you may need to make a key and don't want to affect the values contained
  703.  in the Reg record.
  704. }
  705.  
  706.  
  707. -------------------------------------------------------------------------------
  708.  
  709.  
  710. Function ValidKey(Name1,Name2,Name3 : String;
  711.                   Level : Byte;
  712.                   Key : String) : Boolean;
  713.  
  714. ValidKey will return TRUE, if Key is valid for Name1, Name2, Name3 and Level
  715. (using the pre-defined values of OwnerCode and ProgramCode).  If you do not
  716. wish to use registration levels (and levels weren't used when the key was
  717. generated), simply pass 0 as the Level parameter.  If ValidKey returns FALSE,
  718. the key is not valid.  Unlike the higher-level procedure VerifyKey, this
  719. function does NOT use or change the values of the Reg record.
  720.  
  721.  
  722. Examples :
  723.  
  724.   OwnerCode := 'dfk89ew32zg0imm02';
  725.   ProgramCode := 'RkProg One';
  726.   WriteLn('RkProg 1.3');
  727.   WriteLn;
  728.   Write('Enter your name : ');
  729.   ReadLn(n);
  730.   Write('Enter your BBS name : ');
  731.   ReadLn(b);
  732.   Write('Enter your FidoNet address : ');
  733.   ReadLn(f);
  734.   Write('Enter your registration key : ');
  735.   ReadLn(k);
  736.   If Not ValidKey(n,b,f,0,k) then Begin  { registration levels are not used }
  737.     WriteLn('Invalid key!');
  738.     Halt(1);
  739.   End;
  740.  
  741. {
  742.  This program will prompt the user to enter a name, BBS name, FidoNet address
  743.  and a registration key.   If the registration key is not valid, the program
  744.  will display 'Invalid key!' and Halt with an errorlevel of 1.
  745.  
  746.  It is usually preferable to use the higher-level VerifyKey procedure,
  747.  instead of ValidKey.  ValidKey is included to allow for situations where
  748.  you may need to validate a key and don't want to affect the values contained
  749.  in the Reg record.
  750. }
  751.  
  752.  
  753. -------------------------------------------------------------------------------
  754.  
  755.  
  756. Procedure CreateKey;
  757.  
  758. The procedure CreateKey will use the pre-defined values of OwnerCode and
  759. ProgramCode to generate a key, encrypted from Reg.Name1, Reg.Name2, Reg.Name3,
  760. Reg.Level, Reg.ExpYear and Reg.ExpMonth, with and embedded expiration date,
  761. returning the resulting key in Reg.Key.  If you don't wish to use registration
  762. levels, simply set Reg.Level to 0, before calling CreateKey.  If you don't
  763. wish to use expiration dates, simply set Reg.ExpYear and Reg.ExpMonth to 0,
  764. before calling CreateKey.
  765.  
  766. CreateKey returns the following result codes in Reg.Status :
  767.  
  768. NullProgramCode        OwnerCode was not set
  769. NullOwnerCode          ProgramCode was not set
  770. Registered             Key created successfully
  771.  
  772.  
  773. Examples :
  774.  
  775.   OwnerCode := 'AZ771N91P03DJSS447';
  776.   ProgramCode := 'RkProg';
  777.   WriteLn('Registration Key Maker for RkProg');
  778.   WriteLn;
  779.   WriteLn('FOR INTERNAL USE ONLY!');
  780.   WriteLn;
  781.   Write('Enter name : ');
  782.   ReadLn(Reg.Name1);
  783.   Write('Enter company : ');
  784.   ReadLn(Reg.Name2);
  785.   Write('Enter phone number (XXX) XXX-XXXX : ');
  786.   ReadLn(Reg.Name3);
  787.   Reg.Level := 0;    { registration levels are not being used }
  788.   Reg.ExpYear := 0;  { expiration dates are not being used }
  789.   Reg.ExpMonth := 0;
  790.   CreateKey;
  791.   WriteLn;
  792.   WriteLn('Registration key is '+Reg.Key);
  793.  
  794. {
  795.  This will display a warning message and then prompt for a name, company name
  796.  and phone number.  CreateKey is called and the key is returned in Reg.Key,
  797.  which is displayed.
  798. }
  799.  
  800. Note : It is possible to use CreateKey create keys and then to store the
  801.        contents of the Reg record into your own configuration file (instead
  802.        of using SaveRegInfo) and then read the information into your program
  803.        and use VerifyKey to verify that the key is valid (rather than using
  804.        GetRegInfo).  This way you can keep registration information in your
  805.        own configuration file with other program information, rather than in
  806.        its own .REG file.  If using this method, its important that you save
  807.        Reg.Name1, Reg.Name2, Reg.Name3, Reg.Level, Reg.ExpYear and
  808.        Reg.ExpMonth, so that keys will be built correctly.  You should NEVER
  809.        save OwnerCode to a file of any kind, as this will compromise the
  810.        security of your keys.
  811.  
  812.  
  813. -------------------------------------------------------------------------------
  814.  
  815.  
  816. Procedure VerifyKey;
  817.  
  818. The procedure VerifyKey will use the pre-defined values of OwnerCode and
  819. ProgramCode to generate a key, encrypted from Reg.Name1, Reg.Name2, Reg.Name3,
  820. and Reg.Level, compare the resulting key to Reg.Key, returning the result in
  821. Reg.Status and setting Reg.ExpYear and RegExpDate to the expiration date
  822. encoded in the key.  If you don't wish to use registration levels, simply set
  823. Reg.Level to 0, before calling CreateKey.
  824.  
  825. VerifyKey returns the following result codes in Reg.Status :
  826.  
  827. NullProgramCode        OwnerCode was not set
  828. NullOwnerCode          ProgramCode was not set
  829. Registered             Key is valid
  830. InvalidKey             Key is not valid
  831.  
  832.  
  833. Examples :
  834.  
  835.   OwnerCode := 'dfk89ew32zg0imm02';
  836.   ProgramCode := 'RkProg One';
  837.   WriteLn('RkProg 1.3');
  838.   WriteLn;
  839.   Write('Enter your name : ');
  840.   ReadLn(Reg.Name1);
  841.   Write('Enter your BBS name : ');
  842.   ReadLn(Reg.Name2);
  843.   Write('Enter your FidoNet address : ');
  844.   ReadLn(Reg.Name3);
  845.   Write('Enter your registration key : ');
  846.   ReadLn(Reg.Key);
  847.   Reg.Level := 0;    { registration levels are not used }
  848.   VerifyKey;
  849.   If (Reg.Status <> Registered) then Begin
  850.     WriteLn('Invalid key!');
  851.     Halt(1);
  852.   End;
  853.  
  854. {
  855.  This program will prompt the user to enter a name, BBS name, FidoNet address
  856.  and a registration key.   If the registration key is not valid, the program
  857.  will display 'Invalid key!' and Halt with an errorlevel of 1.
  858. }
  859.  
  860.  
  861. -------------------------------------------------------------------------------
  862.  
  863.  
  864. Procedure GetRegInfo;
  865.  
  866. GetRegInfo will read the key file (if it exists) and set the value of the
  867. following variables :
  868.  
  869.   Reg.Name1     { set to the primary registration name }
  870.   Reg.Name2     { set to the secondary registration name }
  871.   Reg.Name3     { set to the third registration name }
  872.   Reg.Level     { set to the registration level (0 if not used) }
  873.   Reg.ExpYear   { set to the expiration year (0 if not used) }
  874.   Reg.ExpMonth  { set to the expiration month (0 if not used)}
  875.   Reg.Key       { set to the 12 digit alphanumeric registration key }
  876.  
  877. GetRegInfo would generally be called near the beginning of a program (after
  878. OwnerCode, ProgramCode and KeyFile are defined).
  879.  
  880.  
  881. GetRegInfo returns the following result codes in Reg.Status :
  882.  
  883. NotRegistered          Program is not registered
  884. Registered             Program is registered with a valid key
  885. ExpiredKey             Registration key has expired
  886. InvalidKey             Program is registered with an invalid key
  887. FileError              File is corrupt
  888. NullProgramCode        OwnerCode was not set
  889. NullOwnerCode          ProgramCode was not set
  890. InvalidFile            File is not a RkPlus registration key file
  891.  
  892.  
  893. Examples :
  894.  
  895.   OwnerCode := '&,<;(##@["+|~~**=#))';
  896.   ProgramCode := 'RkTest';
  897.   KeyFile := 'RKTEST';
  898.   GetRegInfo;
  899.   If (Reg.Status = Registered) then
  900.     WriteLn('Registered to ' + Reg.Name1);
  901.  
  902. {
  903.  GetRegInfo will read 'RKTEST.REG'.  If the program is registered, Reg.Status
  904.  will be set to Registered and the program will display the name of the person
  905.  that the program is registered to.
  906. }
  907.  
  908.  
  909. -------------------------------------------------------------------------------
  910.  
  911.  
  912. Procedure SaveRegInfo;
  913.  
  914. The procedure SaveRegInfo will use the pre-defined values of OwnerCode and
  915. ProgramCode to generate a key, encrypted from Reg.Name1, Reg.Name2, Reg.Name3,
  916. Reg.Level, Reg.ExpYear and Reg.ExpMonth, with and embedded expiration date,
  917. compare the resulting key with Reg.Key and writing the contents of the Reg
  918. record to the keyfile, returning the result in Reg.Status.  If you don't wish
  919. to use registration levels, simply set Reg.Level to 0, before calling
  920. SaveRegInfo.  If you don't wish to use expiration dates, simply set Reg.ExpYear
  921. and Reg.ExpMonth to 0, before calling SaveRegInfo.
  922.  
  923. SaveRegInfo returns the following result codes in Reg.Status :
  924.  
  925. Registered             Key file was written successfully
  926. InvalidKey             Key is not valid
  927. FileError              Unable to write key file
  928. NullProgramCode        OwnerCode was not set
  929. NullOwnerCode          ProgramCode was not set
  930.  
  931.  
  932. Examples :
  933.  
  934.   OwnerCode := 'Keyboard*Sytem=Load';
  935.   ProgramCode := 'RkProg';
  936.   KeyFile := 'RKPROG';
  937.   WriteLn('RkProg Install Program');
  938.   WriteLn;
  939.   Write('Enter your name : ');
  940.   ReadLn(Reg.Name1);
  941.   Write('Enter your company name : ');
  942.   ReadLn(Reg.Name2);
  943.   Write('Enter your registration key : ');
  944.   ReadLn(Reg.Key);
  945.   Reg.Level := 0;    { registration levels not used }
  946.   Reg.ExpYear := 0;  { expiration dates not used }
  947.   Reg.ExpMonth := 0;
  948.   SaveRegInfo;
  949.   If (Reg.Status <> Registered) then
  950.     WriteLn('Invalid Key.  Program not installed.');
  951.  
  952. {
  953.  This program will prompt the user for a name, company name and a registration
  954.  key.  SaveRegInfo will then be called. If RegStatus does not equal Registered,
  955.  then an error occured and no key file was written (the program displays
  956.  'Invalid Key.  Program not installed.'). Otherwise, RKPROG.REG is written).
  957.  
  958.  
  959. -------------------------------------------------------------------------------
  960.  
  961.  
  962. For more information on using RkPlus, see the sample Turbo Pascal (tm) programs
  963. that are distributed with RkPlus, or contact me at any of the locations listed
  964. below.
  965.  
  966.  
  967. -------------------------------------------------------------------------------
  968.  
  969.  
  970. RkPlus is shareware. You may copy and distribute RKPLUS20.ZIP freely.  All I
  971. ask is that you include all of the original files, unmodified, and that you do
  972. not charge for the distribution of RkPlus itself.  You may use RkPlus for
  973. development of programs for your own use, to give away or to sell.
  974.  
  975.  
  976. If you like RkPlus and use it to develop software, a registration fee of $20
  977. or more toward the continued development of this unit and others like it
  978. would be appreciated.  See REGISTER.FRM for registration information.
  979.  
  980.  
  981. All registrations of RkPlus ($20 or more) register both RkPlus AND rKey
  982. (available as RKEY14.ZIP), allowing you to develop and distribute programs
  983. using either one, or both.  Everyone registering RkPlus with a registration fee
  984. of $20 or more,  will be entitled to have one piece of software (written using
  985. RkPlus/rKey) listed, along with an address or phone number, in an application
  986. list that will be included with all future versions of RkPlus/rKey.
  987. Registrations in excess of $20 will allow multiple applications to be listed.
  988.  
  989.  
  990. There are no royalties for the distribution of programs that are written
  991. with RkPlus.  A single registration fee entitles you to write and distribute
  992. any number of programs using RkPlus and rKey.
  993.  
  994.  
  995. If you have written an application using RkPlus, and wish to have it listed
  996. in the APPLIST.TXT file that is distributed with RkPlus/rKey, please send the
  997. following information via E/Mail, NetMail or US Mail :
  998.  
  999.   Name of Application
  1000.   Programmer's Name (optional)
  1001.   Copyright Notice
  1002.   Address or Phone Number
  1003.   System Requirements
  1004.   Cost of Program (optional)
  1005.   Any Additional Information (optional)
  1006.  
  1007.  
  1008. Questions, comments, and suggestions are welcome.
  1009.  
  1010. Send E/Mail to   Scott Davis
  1011.                  Phoenix StarFighter BBS [3/12/24/HST]
  1012.                  Phone (404) 869-3410
  1013.                  FidoNet Node 1:3616/20
  1014.  
  1015. Send US Mail to  Scott Davis
  1016.                  Rt. 2 Box 95
  1017.                  County Line Drive
  1018.                  Lula, GA 30554
  1019.  
  1020.  
  1021. -------------------------------------------------------------------------------
  1022.  
  1023.  
  1024. I'd like to thank Danny Sosebee (Sysop of Phoenix StarFighter BBS) for
  1025. allowing me to use his BBS as a way to receive suggestions and comments
  1026. regarding RkPlus.  Also, I'd like to thank Ed Ivey (Sysop of Ed's Place
  1027. BBS - 404/532-1978 - FidoNet Node 1:3616/1) for his continued support
  1028. and assistance in distributing my little software "projects".
  1029.  
  1030.  
  1031. -------------------------------------------------------------------------------
  1032.  
  1033.  
  1034.       Turbo Pascal (tm) units available from Serious Cybernetics :
  1035.  
  1036.           StrLib 1.2          TP 5.5 String Functions Library Unit
  1037.           rKey 1.4            TP 5.5/6.0 Registration Key Unit
  1038.           RkPlus 2.0          TP 5.5/6.0 Registration Key Unit (enhanced)
  1039.  
  1040.  
  1041. ------------------------------------------------------------------------------
  1042.  
  1043. RkPlus (c) 1991 Serious Cybernetics
  1044. rKey, StrLib (c) 1990, 1991 Serious Cybernetics
  1045. Turbo Pascal (c) 1983, 1989 Borland International
  1046.  
  1047.  
  1048.